package com.example.myapplication;

import android.os.Bundle;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;
import androidx.viewpager.widget.ViewPager;

import com.example.myapplication.fragment.FragmentAdapter;
import com.example.myapplication.fragment.Tab1Fragment;
import com.example.myapplication.fragment.Tab2Fragment;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ViewPager viewPager = findViewById(R.id.vp);

        List<Fragment>list=new ArrayList<>();
        Tab1Fragment tab1=new Tab1Fragment();
        list.add(tab1);

        Tab2Fragment tab2_=new Tab2Fragment();
        list.add(tab2_);
        FragmentAdapter adapter=new FragmentAdapter(getSupportFragmentManager(),list);

        viewPager.setAdapter(adapter);


    }


}